<template>
  <div class="home">
    <el-container style="height: 100%;">
      <el-header style="background-color: orange;">Header</el-header>
      <el-container>
        <el-aside width="200px" style="background-color: pink;">
          <el-menu router default-active="2" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose">
            <el-sub-menu index="1">
              <template #title>
                <el-icon>
                  <location />
                </el-icon>
                <span>用户管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/users/index" router>用户查询</el-menu-item>
                <el-menu-item index="/users/add">新增用户</el-menu-item>
              </el-menu-item-group>
              <el-menu-item-group>
                <el-menu-item index="/users/update">修改用户</el-menu-item>
                <el-menu-item index="/users/delete">删除用户</el-menu-item>
              </el-menu-item-group>
            </el-sub-menu>
            <el-menu-item index="2">
              <el-icon><icon-menu /></el-icon>
              <span>角色管理</span>
            </el-menu-item>
            <el-menu-item index="4">
              <el-icon>
                <setting />
              </el-icon>
              <span>系统配置</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main style="background-color: olive;">
          <div>二级路由信息</div>
          <router-view v-slot="{ Component }">
            <keep-alive>
              <component :is="Component" :key="$route.name" v-if="$route.meta.keepAlive" />
            </keep-alive>
            <component :is="Component" :key="$route.name" v-if="!$route.meta.keepAlive" />
          </router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup>
import {
  Menu as IconMenu,
  Location,
  Setting,
} from '@element-plus/icons-vue'

const handleOpen = (key, keyPath) => {
  console.log(key, keyPath)
}
const handleClose = (key, keyPath) => {
  console.log(key, keyPath)
}
</script>

<style lang='less' scoped>
.home {
  height: 100%;
  background-color: orange;
}
</style>